﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <!-- This button style attempts to subtly draw attention to itself when it is enabled.
         The button display consists of two rectanges, upper/lower, with different colors
         and a content presenter which displays the text. The control animates when changing
         from enabled to disabled and vice versa. Additionally, the press event is animated.
    -->
    <Style TargetType="Button" x:Key="AnimatedEnableButtonStyle" >
        <Setter Property="Margin" Value="5" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" TextBlock.Foreground="Black" 
                                 RenderTransformOrigin=".5,.5" Name="theBorder" >
                        <Border.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform x:Name="scaleTransform" />
                            </TransformGroup>
                        </Border.RenderTransform>
                        <Grid >
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Rectangle Name="topBackground" Fill="WhiteSmoke"  />
                            <Rectangle Grid.Row="1" Name="bottomBackground" Fill="LightGray" />
                            <ContentPresenter Grid.RowSpan="2" VerticalAlignment="Center" 
                                              HorizontalAlignment="Center" Margin="5 0" >
                                <ContentPresenter.RenderTransform>
                                    <TranslateTransform x:Name="translateTransform" />
                                </ContentPresenter.RenderTransform>
                            </ContentPresenter>
                        </Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup Name="CommonStates">
                                <VisualState Name="Disabled">
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="topBackground"
                                                            Storyboard.TargetProperty="(Rectangle.Fill).(Color)"
                                                            To="White" Duration="0:0:.5" />
                                        <ColorAnimation Storyboard.TargetName="bottomBackground"
                                                            Storyboard.TargetProperty="(Rectangle.Fill).(Color)"
                                                            To="WhiteSmoke" Duration="0:0:0.5" />
                                        <ColorAnimation Storyboard.TargetName="theBorder"
                                                            Storyboard.TargetProperty="(TextBlock.Foreground).(Color)"
                                                            To="Gray" Duration="0:0:0.5" />
                                    </Storyboard>
                                </VisualState>

                                <VisualState Name="Normal">
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="topBackground"
                                                        Storyboard.TargetProperty="(Rectangle.Fill).Color"
                                                        To="PeachPuff" Duration="0:0:0.5" />
                                        <ColorAnimation Storyboard.TargetName="topBackground"
                                                        Storyboard.TargetProperty="(Rectangle.Fill).Color"
                                                        BeginTime="0:0:0.5"
                                                        To="WhiteSmoke" Duration="0:0:0.5" />
                                        
                                        <ColorAnimation Storyboard.TargetName="bottomBackground"
                                                        Storyboard.TargetProperty="(Rectangle.Fill).Color"
                                                        To="LightYellow" Duration="0:0:0.5"
                                                        />
                                        <ColorAnimation Storyboard.TargetName="bottomBackground"
                                                        BeginTime="0:0:0.5"
                                                        Storyboard.TargetProperty="(Rectangle.Fill).(Color)"
                                                        To="LightGray" Duration="0:0:0.5" />
                                        
                                        <ColorAnimation Storyboard.TargetName="theBorder"
                                                            Storyboard.TargetProperty="(TextBlock.Foreground).Color"
                                                            To="Black" Duration="0:0:0.5" />

                                        <ColorAnimation Storyboard.TargetName="theBorder"
                                                            Storyboard.TargetProperty="BorderBrush.Color"
                                                            From="Black" To="DarkBlue" Duration="0:0:1" AutoReverse="True" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="scaleTransform"
                                                             Storyboard.TargetProperty="ScaleX" 
                                                             To=".9" 
                                                             Duration="0" />
                                        <DoubleAnimation Storyboard.TargetName="scaleTransform"
                                                             Storyboard.TargetProperty="ScaleY"
                                                             To=".9" Duration="0" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <!--<Style.Triggers>
            <DataTrigger Binding="{Binding TextRemoved,RelativeSource={RelativeSource AncestorType=Window}}">
                <DataTrigger.EnterActions>
                    <BeginStoryboard Name="AnimateTextbox">
                        <Storyboard>
                            <DoubleAnimation 
                                Storyboard.TargetProperty="(TextBlock.RenderTransform).(TranslateTransform.X)" Duration="0:0:0.5"
                                From="0" To="500" />
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.EnterActions>
            </DataTrigger>
        </Style.Triggers>-->
    </Style>
</ResourceDictionary>